package 并发编程16.消息发送场景;

import java.util.concurrent.DelayQueue;

/**
 * @author idea
 * @data 2019/2/10
 */
public class Consumer implements Runnable {

    private DelayQueue<Message> queue;

    public Consumer(DelayQueue<Message> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while(true){
            try {
                Message message=queue.take();
                System.out.println("消费者id："+message.getId()+"mess:"+message.getBody());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
